import path from "path"
import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
import AutoImport from "unplugin-auto-import/vite"
import Components from "unplugin-vue-components/vite"
import { ElementPlusResolver } from "unplugin-vue-components/resolvers"
import Icons from "unplugin-icons/vite"
import IconResolver from "unplugin-icons/resolver"
import Inspect from "vite-plugin-inspect" // 查看文件的相互依赖

const pathSrc = path.resolve(__dirname, "./src")

export default defineConfig({
	plugins: [
		vue(),
		AutoImport({
			resolvers: [ElementPlusResolver(), IconResolver({ prefix: "Icon" })],
			dts: path.resolve(pathSrc, "auto-imports.d.ts"),
		}),
		Components({
			resolvers: [ElementPlusResolver(), IconResolver({ enabledCollections: ["ep"] })],
			dts: path.resolve(pathSrc, "components.d.ts"),
		}),
		Icons({ autoInstall: true }),
		Inspect(),
	],
	resolve: {
		alias: {
			"@": pathSrc,
		},
	},
})
